package com.example.test1;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.example.test1.adapter.ViewPagerAdapter;

public class SplashActivity extends Activity{

	private ViewPager vp;
	
	private List<View> views;
	
	private ViewPagerAdapter adapter;
	
	private Button start_btn;
	
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		initViews();
		
	}



	private void initViews() {
		LayoutInflater inflater = LayoutInflater.from(this);
		views = new ArrayList<View>();
		views.add(inflater.inflate(R.layout.one, null));
		views.add(inflater.inflate(R.layout.two, null));
		views.add(inflater.inflate(R.layout.three, null));
		
		adapter = new ViewPagerAdapter(this, views);
		
		vp = (ViewPager) findViewById(R.id.viewPager);
		
		vp.setAdapter(adapter);
		
		
		start_btn=(Button) views.get(2).findViewById(R.id.start_btn);
		start_btn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent=new Intent(SplashActivity.this,MainActivity.class);
				startActivity(intent);
				SplashActivity.this.overridePendingTransition(R.anim.activity_move_in_start, R.anim.activity_move_out_start);
				//当前页面不在需要了
				finish();
			}
		});
	}
}
